package org.vectrics.recruiter.struts.admin;

import javax.servlet.jsp.JspException;

import org.apache.log4j.Category;
import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.recruiter.user.RecruitUserProvider;
import org.vectrics.recruiter.user.Resume;
import org.vectrics.struts.VectricsStrutsAction;
import org.vectrics.struts.VectricsActionData;


public class DeleteResumeAction extends VectricsStrutsAction {
    private static Category log = Category.getInstance(DeleteResumeAction.class);
	public static String USER_ID_PARAM = "userId";

	protected void authorizationCheck(Resume resume) {
	}


	// Intercept 
	@Override
	protected String doExecute(VectricsActionData actionData)	throws JspException {
		String resumeId = actionData.getRequest().getParameter("resumeId");
		try {
			Resume resume = RecruitServiceLocator.getRecruitUserService().findResume(new Long(resumeId));
			authorizationCheck(resume);
			resume.setVoided(true);
			RecruitServiceLocator.getRecruitUserService().updateResume(resume);
			
		}
		catch (Exception ex) {
			log.error("Exception saving file to server drive", ex);
			throw new JspException("Exception saving file to server drive", ex);
		}
		
		return ("success");
	}
}
